<!DOCTYPE html>
<html lang="en" dir="ltr">

<head>
    <meta charset="utf-8">
    <title>间</title>
    <script src="https://s3.pstatp.com/cdn/expire-1-M/jquery/3.0.0/jquery.min.js"></script>
</head>

<body>

<form id="form-signin">
    <input type="text" id="userId"/>
    <button type="button" onclick="clickFun();">click</button>
</form>

</body>

<script type="text/javascript">

    function clickFun() {
        var uid = $("#userId").val();
        var today=new Date();
        var time="20201010"; //today.toLocaleString('chinese', { hour12: false });
        var action="click";
        var jobCode="XE8293"
        $.ajax({
            type: "GET",
            url: "/behaviortrack/clickevent?uid="+uid+"&time="+time+"&action="+action+"&jobCode="+jobCode,
            dataType: "json",
            success: function (result) {
                alert(result.resmsg);
                clickFunNginx(uid, time, action, jobCode);
            },
            error: function (data) {
                alert("请求出错");
                alert(data);
            }
        });
    }

    function clickFunNginx(uid, time, action, jobCode) {
        $.ajax({
            type: "POST",
            url: "http://com01/kafka/track",
            key: uid,
            data :JSON.stringify({
                "uid" :uid,
                "time":time,
                "action":action,
                "jobCode":jobCode}),
            dataType: "text",
            success: function (result) {
                alert("已成功发送至nginx！");
            },
            error: function (data) {
                alert("请求出错");
                alert(data);
            }
        });
    }

</script>

</html>